package com.firebugsoft.metadata.api.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.firebugsoft.common.mvc.json.Body;
import com.firebugsoft.metadata.dubbo.api.IDictionaryService;
import com.firebugsoft.metadata.dubbo.api.to.DictionaryTO;

@RestController
@RequestMapping(value = { "/dictionary" })
public class DictionaryController {
    @Resource
    private IDictionaryService dictionaryService;

    @RequestMapping(value = { "/find" })    
    public Body find(String code) {
        DictionaryTO to = dictionaryService.findByCode(code);
        return Body.newInstance(to);
    }

    @RequestMapping(value = { "/list" })    
    public Body list(String pcode) {
        List<DictionaryTO> tos = dictionaryService.findByPcode(pcode);
        return Body.newInstance(tos);
    }
}
